from django.conf.urls import url

from . import views


urlpatterns = [
    # /weather/beijing/2018
    # 演示匹配逻辑
    # url(r'^weather/[a-z]+/\d{4}/$', views.weather),
    # 利用正则组来提取URL参数-位置参数
    # url(r'^weather/([a-z]+)/(\d{4})/$', views.weather),
    # 利用正则组起别名 来提取URL参数-关键字参数
    # 注意:正则组中的别名一定要和视图中的参数名一样
    url(r'^weather/(?P<city>[a-z]+)/(?P<year>\d{4})/$', views.weather2),

    # 演示提取查询字符串
    url(r'^query_str/$', views.query_str),
    # 演示提取请求体中的表单数据
    url(r'^body_form/$', views.body_form),
    # 演示提取请求体中的非表单数据
    url(r'^body_json/$', views.body_json),

    # 演示获取请求头信息
    url(r'^request_head/$', views.request_head),
    # 演示响应常规操作
    url(r'^response_demo/$', views.response_demo),
    # 演示响应json
    url(r'^response_json/$', views.response_json),

    # 演示命名空间和反向解析  name参数表示给路由起一个别名
    url(r'^reverse_demo/$', views.reverse_demo, name='reverse_demo'),

    # 演示重定向
    url(r'^redirect_demo/$', views.redirect_demo),

    # cookie缓存读写
    url(r'^cookie_demo/$', views.cookie_demo),

    # 演示session读写
    url(r'^session_demo/$', views.session_demo),
]